﻿<!doctype html>
 <html lang="zh-CN">
 <head>
   <meta charset="UTF-8">
   <link rel="stylesheet" href="/css/common.css">
   <link rel="stylesheet" href="/css/main.css">
   <script type="text/javascript" src="/js/jquery.min.js"></script>
   <script type="text/javascript" src="/js/colResizable-1.3.min.js"></script>
   <script type="text/javascript" src="/js/common.js"></script>
</head>
<body>
  &nbsp;文档回收站
  <form id="form" action="/resource/wendang/demo2/list" method="get">
	  <input type="hidden" name="page" id="page">
  </form>
 <div id="table" class="mt10">
        <div class="box span10 oh">
			<form id="myform" method="post" action="/resource/wendang/deleteAll">
				<input type="hidden" name="method" id="mymethod">
              <table width="100%" border="0" cellpadding="0" cellspacing="0" class="list_table">
                <tr>
				   <th> <input id="checkall" onclick="checkAll()" type="checkbox"></th>
                   <th>名称</th>
                   <th>类型</th>
                   <th>所有者</th>
				   <th>删除时间</th>
				   <th>操作</th>
                </tr>
				  <#list listDoc.list as ld>
					  <tr class="tr" align="center">
						  <td class="td_center"><input onclick="docheckAll()" type="checkbox" name="wordId" value="${ld.wordId}"></td>
						  <td>${ld.wordName}</td>
						  <td>${ld.wordType}</td>
						  <td>${ld.userName}</td>
						  <td>${ld.wordTime?string("yyyy-MM-dd")}</td>
						  <td>
							  <a href="javascript:void(0)" onclick="del1(${ld.wordId})">还原</a> |&nbsp;
							  <a href="javascript:void(0)" onclick="del(this,${ld.wordId})">删除</a>
						  </td>
					  </tr>
				  </#list>
               <tr>
			   <td colspan="2">
				   <input type="button" class="btn btn82 btn_del" value="删除" onclick="delall()">
			    	<input type="button" class="btn btn82 btn_export" value="导出" onclick="excel()">
				</td>
				<td colspan="5" align="right">
				     <div class="page mt10">
						<div class="pagination">
							<ul>
							  	<li class="first-child"><a href="javascript:;" onclick="page(1)">首页</a></li>
							  	<li class=""><a href="javascript:;" onclick="page(${listDoc.pageNum - 1})">上一页</a></li>
							  <#--<#list begin="${listDoc.navigateFirstPage}" end="${listDoc.navigateLastPage}" varStatus="i">
								  <a href="javascript:;" onclick="page(${i.index})">${i.index}</a>
							  </>&ndash;&gt;-->
								  <li><a href="javascript:;" onclick="page(${listDoc.pageNum + 1})">下一页</a></li>
								  <li><a href="javascript:;" onclick="page(${listDoc.pages})">尾页</a></li>
							   <li ><span>共${listDoc.total}条数据</span></li>
					     <li><span>共${listDoc.pages}页</span></li>
							</ul>
						</div>
					 </div>
				</td>
			   </tr>
              </table>
			</form>
        </div>
     </div>
<script>
	var checkall, item;
	checkall = document.getElementById("checkall");
	item = document.getElementsByName("wordId");
	//全选框判断：全选 全不选
	function checkAll() {
		for (var i = 0; i <item.length; i++) {
			if(checkall.checked){
				item[i].checked = true;
			}else{
				item[i].checked = false;
			}
		}
	}
	//单选框判断:如果单选框被选中的数量和单选框的数量相等的时候全选框选中，反之没有被选中；
	function docheckAll(){
		var count=0;
		for (var i = 0; i <item.length ; i++) {
			if(item[i].checked){
				count++;
			}
		}
		if(count===item.length){
			checkall.checked = true;
		}else{
			checkall.checked = false;
		}
	}


	function page(page) {
		$("#page").val(page);
		$("#form").submit();
	}

	function del(obj,id){
		if (confirm("确认不要我了吗？") == true){
			$.post(
					"/resource/wendang/del"
					,{id:id}
					,function (result) {
						if (result.code == 0){
							alert("删除成功")
							$(obj).parent().parent().remove();
							location.href = "/resource/wendang/demo2/list";
						} else {
							alert("删除失败");
						}
					}
					,"json"
			);
			return true;
		} else {
			return false;
		}
	}
	function del1(id){
		if (confirm("确认还原吗？") == true){
			$.post(
					"/resource/wendang/huanyuan"
					,{id:id}
					,function (result) {
						if (result.code == 0){
							alert("还原成功");
							location.href = "/resource/wendang/demo2/list";
						} else {
							alert("还原失败");
						}
					}
					,"json"
			);
			return true;
		} else {
			return false;
		}
	}
	//多选删除
	function delall(){
		if (confirm("确认删除？") == true){
			//设置隐藏域的值
			document.getElementById("mymethod").value="delete";
			//提交表单
			//document.getElementById("myform").submit();
			document.forms[1].submit();

			return true;
		} else {
			return false;
		}
	}
	//导出
	function excel(){
		if (confirm("确认导出吗？") == true){
			//设置隐藏域的值
			document.getElementById("mymethod").value="daochu";
			//提交表单
			// document.getElementById("myform").submit();
			document.forms[1].submit();

			return true;
		} else {
			return false;
		}
	}
</script>
</body>
</html>
